package com.sharer.last.controller;

import com.sharer.last.base.constant.CommonConstant;
import com.sharer.last.base.model.PageVO;
import com.sharer.last.base.model.R;
import com.sharer.last.model.dto.log.OperationLogQueryDTO;
import com.sharer.last.model.vo.log.OperationLogVO;
import com.sharer.last.service.OperationLogService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 操作日志后台管理
 *
 * @ClassName OperationLogController
 * @Author wangjin
 * @Date 2023/5/5 21:04
 * @Description
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.BLOG_ADMIN_API + "/operation/log")
public class OperationLogController {
	@Resource
	OperationLogService operationLogService;

	/**
	 * 分页查询操作日志列表
	 *
	 * @param operationLogDTO
	 * @return
	 */
	@PostMapping("/page")
	public R<PageVO<OperationLogVO>> page(@RequestBody OperationLogQueryDTO operationLogDTO) {
		PageVO<OperationLogVO> pageList = operationLogService.selectListByPage(operationLogDTO);
		return R.success(pageList);
	}

	/**
	 * 按id删除操作日志
	 *
	 * @param id 日志id
	 * @return
	 */
	@DeleteMapping("/delete")
	public R delete(@RequestParam Long id) {
		operationLogService.removeOperationLogById(id);
		return R.handle();
	}
}
